package com.zsummer.test.yimian;

/**
 * @author zsummer
 * @since 2022/3/9
 */
public class Solution {

    int count = 0;

    public int binaryTreePaths(TreeNode root) {
        if (root == null) {
            return 0;
        }
       bianli(root);
       return count;
    }

    public boolean isLeaf(TreeNode node) {
        return node.left ==null && node.right == null;
    }

    public void bianli(TreeNode node) {
        if(isLeaf(node)) {
            count++;
        } else {
            if (node.left != null) {
                bianli(node.left);
            }
            if (node.right != null) {
                bianli(node.right);
            }
        }
    }


}
